package algorithm;

public class leetcode_1 {

    public  void rotate(int[] nums, int k) {
        int len=nums.length;
        k%=len;
        reverse(0,len-1,nums);
        reverse(0,k-1,nums);
        reverse(k,len-1,nums);
    }
    public void reverse(int begin,int end,int[] nums){
        int left=begin;
        int right=end;
        for(;left<right;left++,right--){
            int temp=nums[left];
            nums[left]=nums[right];
            nums[right]=temp;
        }
    }
}
